﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="adminlist.aspx.cs" Inherits="UI.system.page.admin.adminlist" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="/system/js/jquery.min.js"></script>
    <script src="/system/layui/layui.js"></script>
    <script src="/system/layui/lay/modules/laydate.js"></script>
    <script src="/system/js/common.js"></script>
    <script src="/system/js/md5.js"></script>
    <link rel="stylesheet" href="/system/layui/css/layui.css">
    <link rel="stylesheet" href="/system/css/iframe.css">
    <link rel="stylesheet" href="/system/css/viewer.css">
    <script src="/system/js/viewer.js"></script>
    <style>
        td img{border-radius:20px; width:40px; height:40px; float:left; margin-left:5px;}
    </style>
</head>
<body>
    
    <form id="form1" runat="server">
    <div class="layer-toolbar layui-form">
        <div class="layer-toolbar-left">
            <div style="position:absolute; left:-1000px; top:-1000px;"><input type="radio" name="radio"  value="" title="" /></div>
            <a class="layui-btn layui-btn-small" onclick="Save_Admin(0)">新增</a>
        </div>
        <div class="layer-toolbar-right">
            <input id="begindate" type="text" name="title" placeholder="开始时间" autocomplete="off" class="layui-input" value="" style="width:100px;" onclick="layui.laydate({elem: this, format: 'YYYY-MM-DD'})"><div class="texts">-</div>
            <input id="enddate" type="text" name="title" placeholder="结束时间" autocomplete="off" class="layui-input" value="" style="width:100px;" onclick="layui.laydate({elem: this, format: 'YYYY-MM-DD'})">
            <input id="keyword" type="text" name="title" placeholder="用户名、姓名" autocomplete="off" class="layui-input" value="" style="width:150px;" onkeyup='CRM.Enter("#search")'>
            <a id="search" class="layui-btn layui-btn-small layui-btn-normal" onclick="Search()">搜索</a>
            <a class="layui-btn layui-btn-small" onclick="Search()">刷新</a>
        </div>
    </div>
    <div id="iframe" class="layer-iframe">
    <div class="layui-form">
    <table class="layui-table">
    <colgroup>
      <col width="120">
      <col>
      <col width="120">
      <col width="120">
      <col width="120">
      <col width="120">
    </colgroup>
    <thead>
      <tr>
        <th>用户名</th>
        <th>姓名</th>
        <th>会员数量</th>
        <th>角色</th>
        <th>创建时间</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody id="layer-table">
        <tr><td colspan="11" class="center">数据加载中...</td></tr>
    </tbody>
     <script id="data-table" type="text/html">
      {{#  layui.each(d, function(index, item){ }}
      <tr>
        <td>{{item.UserName}}</td>
        <td>{{item.RealName}}</td>
        <td>{{item.UserCount}}</td>
        <td>{{item.Role==1?"系统管理员":"代理商"}}</td>
        <td>{{item.CreateDate.ToDate()}}</td>
        <td style="line-height:30px;">
        <a class="layui-btn layui-btn-mini" onclick="Save_Admin({{item.ID}})">编辑</a>
        <a class="layui-btn layui-btn-mini layui-btn-danger" onclick="Delete_Admin(this,{{item.ID}})">删除</a>
        </td>
      </tr>
      {{#  }); }}
      </script>
  </table>
    </div>
    </div>
    <div id="layer-page" class="layer-page"></div>
    </form>
    <script>
        layui.use(['form', 'laytpl', 'element'], function () {
            $ = layui.jquery, form = layui.form(), laytpl = layui.laytpl;
            Init_Pager(1);
        });

        function Init_Pager(pageindex) {
            var data = {};
            data.act = "Find_Admin";
            data.pageindex = pageindex;
            data.parentid = $(".layui-table").attr("parentid");
            data.begindate = $("#begindate").val();
            data.enddate = $("#enddate").val();
            data.keyword = $("#keyword").val();
            data.sign = GetSign(data.act);
            Loading();
            Ajax.Post("/tools/Admin.ashx", data, function (r) {
                var json = $.parseJSON(r);
                if (json.state) {
                    Pager(json.data.list, json.data.count);
                }
                else {
                    LayerBox.Error(json.msg);
                }
            });
        };


        function Save_Admin(id) {
            LayerBox.Loading();
            Ajax.Get("/system/page/admin/adminadd.aspx?id=" + id + "&v=" + Math.random(), function (html) {
                LayerBox.Close.ByAll();
                var title = id == 0 ? "新增" : "修改";
                window.parent.LayerBox.Show(title + "", html, 630, 400, null, function (form) {
                    var data = form;
                    data.act = "Save_Admin";
                    data.id = id;
                    data.sign = GetSign(data.act);
                    data.power = "";// CRM.ListValue(".checkbox input:checked");
                    LayerBox.Loading();
                    Ajax.Post("/tools/Admin.ashx", data, function (r) {
                        var json = $.parseJSON(r);
                        if (json.state) {
                            LayerBox.Success(json.msg, 500, function () {
                                LayerBox.Close.ByAll();
                                if (id == 0) {
                                    $(".layui-laypage").remove();
                                    Init_Pager(1);
                                } else {
                                    var currpage = 1;
                                    if ($(".layui-laypage-curr em").length > 0) {
                                        currpage = $(".layui-laypage-curr em")[1].innerHTML;
                                    }
                                    Init_Pager(currpage);
                                }
                            });
                        }
                        else {
                            LayerBox.Error(json.msg);
                        }
                    });
                });
            });
        };



        function Delete_Admin(o, id) {
            LayerBox.Confirm("您确定要删除吗？", function () {
                Delete_Table(o, id, "Delete_Admin");
            });
        };


        
</script>
</body>
</html>
